﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%	dim rs,sql,i,id,zf,down,nid,gm,viphy,viphy2,zf2,FileUrl,downtime,name,phonename
	id=Request.QueryString("id")
	if id="" then id=0
	if not isnumeric(id) then id=0
	id=clng(id)
         phonename=qingtian.phonename(midqd,1)
	Set Rs = Server.CreateObject("Adodb.Recordset")
		Sql = "select top 1 *  FROM qingtian_phoneurl where aid="&id&" and (bid="&phonename&" or bid=0) Order by id desc"
		rs.open sql,conn,1,1
                if not (rs.bof and rs.eof)  then
		FileUrl=rs("FileUrl")
                else
                if v=0 then
                Response.Write "<card id=""add"" title=""出错了""><p align=""left"">"
                else
                Response.Write "<title>出错了</title></head><body>"
                end if
                qingtian.err("该软件下载地址不存在")
                end if
		rs.Close
	if sid<>"Null" then
	Sql = "select vip,id from qingtian_user where sid='"&md5(sid) & md5(strReverse(sid))&"'"
	Rs.Open Sql,conn,1,1

	if not (rs.bof and rs.eof)  then
		viphy=rs("vip")
		nid=rs("id")
	end if
	Rs.close	

	Sql = "select id from qingtian_paym where ext=1 and listid="&id&" and  nid="&nid&""
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		gm=1
	else
		gm=0
	end if
	Rs.close	


	else
		gm=0
		viphy=0
	end if




	Sql = "select name,VIP,zf,viphy,vipgm,downtime from qingtian_fileli where id="&id
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		viphy2=rs("viphy")
		zf2=rs("zf")
		downtime=rs("downtime")
		name=rs("name")

		if viphy=1 then
			if rs("vipgm")=1 then
				if gm=1 then
					down=true
				else
					down=false
				end if

			else
				down=true
			end if
		elseif rs("viphy")=1 then
			down=false
		elseif rs("vip")=1 then
				if gm=1 or rs("zf")=0 then
					down=true
				else
					down=false
				end if
		else
			down=true

		end if

	end if
	Rs.close	
	set rs=nothing


		if down=true then
               	 	conn.execute("update qingtian_fileli set [downcount]=[downcount]+1,[downtime]='" & Now() & "' where [id]=" & id & "")

            		If DateDiff("m", downtime, Now()) > 0 Then
               	 		conn.execute("update qingtian_fileli set [Monthdown]=1 where [id]=" & id & "")
            		Else
                		conn.execute("update qingtian_fileli set [Monthdown]=[Monthdown]+1 where [id]=" & id & "")
            		End If

            		If DateDiff("ww", downtime, Now()) > 0 Then
                		conn.execute("update qingtian_fileli set [Weekdown]=1 where [id]=" & id & "")
            		Else
                		conn.execute("update qingtian_fileli set [Weekdown]=[Weekdown]+1 where [id]=" & id & "")
            		End If

            		If DateDiff("d", downtime, Now()) > 0 Then
                		conn.execute("update qingtian_fileli set [Daydown]=1 where [id]=" & id & "")
           		Else
                		conn.execute("update qingtian_fileli set [Daydown]=[Daydown]+1 where [id]=" & id & "")
            		End If

select case v
case "0"
we0="<br/>"
%>
<card title="文件下载" ontimer="<%=qingtian.utf8(FileUrl)%>"><timer value="30"/><p align="<%=qingtian.px%>">
<%
case "1"
hr="<hr>"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<meta name="keywords" content=",版本V1.0"/>
<meta name="author" content="晴天建站系统"/>
<meta http-equiv="Cache-Control" content="max-age=0" forua="true"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Refresh" content="1; url=<%=qingtian.utf8(FileUrl)%>">
<title>文件下载</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select

%>

<%


			if sid="Null" then
			%><%=dao%><%=zi%>欢迎你<%=zi0%><a href="login.asp?sid=<%=sidd%>&amp;url=down.asp?id=<%=id%>">注册/登陆</a><%=we0%><%
			else
			qingtian.info
                        qingtian.addong("下载了文件[url=/fileve.asp?id="&id&"&sid=[sid]]"&name&"[/url]")
			end if

			%><%=we%>正在自动下载文件!如果无法自动下载,请<a href="<%=qingtian.utf8(FileUrl)%>">手动下载</a><%=we0%><%
		else

select case v
case "0"
we0="<br/>"
%>
<card title="文件下载" ontimer="fileve.asp?sid=<%=sidd%>&amp;id=<%=id%>"><timer value="30"/><p align="<%=qingtian.px%>">
<%
case "1"
hr="<hr>"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<meta name="keywords" content=",V1.0"/><meta name="author" content="晴天"/><meta http-equiv="Cache-Control" content="max-age=0" forua="true"/><meta http-equiv="Cache-Control" content="no-cache"/><meta http-equiv="Expires" content="0"/><meta http-equiv="Refresh" content="1; url=fileve.asp?sid=<%=sidd%>&id=<%=id%>">
<title>文件下载</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select

%>
<%

			if viphy2=1 then
				if viphy=1  then
				%><%=we%>你还没有购买!,购买需<%=qingtian.bi%><%=we0%><%=sou%><a href="paym.asp?ext=1&amp;id=<%=id%>&amp;sid=<%=sidd%>">马上购买</a><%=we0%><%
				else
				%><%=we%>下载文件出错!该文件为VIP会员下载.请确认你为VIP会员!<%=we0%><%
				end if
			else
				if sid<>"Null" then
				%><%=we%>你还没有购买,购买需<%=qingtian.bi%><%=we0%><%=sou%><a href="paym.asp?ext=1&amp;id=<%=id%>&amp;sid=<%=sidd%>">马上购买</a><%=we0%><%
				else
				%><%=we%>下载文件出错!该文件为会员下载.请先登陆再下载!<%=we0%><%
				end if
			end if

		end if
%>	
<%=dao%>---------------<%=we0%>
<%
   		    Response.Write(""&sou&"<a href='fileve.asp?id="&id&"&amp;sid="&sidd&"'>返回文件下载</a>"&we0&"")

%>

<%

end Function
%>
